package org.wxd.account.domain.user;

import javax.persistence.*;
import java.io.Serializable;

/**
 * Created by wangxd on 2015/10/6.
 */
@Embeddable
@Access(AccessType.FIELD)
public class UserMoreInfo implements Serializable {
    private static final long serialVersionUID = 6712535531533616803L;
    private static final String NAME = "name";
    private static final String TYPE = "type";
    private static final String IS_ACTIVE = "is_active";



    /**
     * 用户类型，购买者，售出者，管理员
     */
    public enum Type {
        PURCHASER, SELLER, ADMIN
    }

    @Column(name = TYPE)
    @Enumerated(EnumType.STRING)
    private Type type;
    @Column(name = NAME)
    private String name;
    @Column(name = IS_ACTIVE)
    private boolean isActive;

    UserMoreInfo() {
    }

    UserMoreInfo(Builder builder) {
        this.type = builder.type;
        this.name = builder.name;
        this.isActive = builder.isActive;
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public Type type() {
        return type;
    }
    public UserMoreInfo active(boolean active) {
        this.isActive = active;
        return this;
    }
    public String name() {
        return name;
    }
    public UserMoreInfo name(String name) {
        this.name = name;
        return this;
    }

    public boolean isActive() {
        return isActive;
    }

    public static class Builder {

        Type type;
        String name;
        boolean isActive;

        public Builder type(Type type) {
            this.type = type;
            return this;
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder isActive(boolean isActive) {
            this.isActive = isActive;
            return this;
        }

        public UserMoreInfo build() {
            return new UserMoreInfo(this);
        }

    }


}
